home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2001 January / Game.EXE_01_2001.iso / demos / Blade of Darkness / data1.cab / Program_Executable_Files / Lib / Sounds.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-11-16  |  3.8 KB  |  82 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. import Bladex
  5. import whrandom
  6. import ObjStore
  7. import GameStateAux
  8.  
  9. def RepeatPeriodicSound(persound):
  10.     if persound.OnPlay:
  11.         persound.sound.PlaySound(0)
  12.         variation = whrandom.uniform(-(persound.frec_variation), persound.frec_variation)
  13.         Bladex.AddScheduledFunc(Bladex.GetTime() + persound.frecuency + variation, RepeatPeriodicSound, (persound,), 'RepeatPeriodicSound')
  14.     
  15.  
  16.  
  17. class PeriodicSound:
  18.     OnPlay = 0
  19.     ObjId = None
  20.     sound = None
  21.     frecuency = 0
  22.     frec_variation = 0
  23.     
  24.     def __init__(self):
  25.         self.ObjId = ObjStore.GetNewId()
  26.         ObjStore.ObjectsStore[self.ObjId] = self
  27.  
  28.     
  29.     def PlayPeriodic(self):
  30.         self.OnPlay = 1
  31.         self.sound.PlaySound(0)
  32.         variation = whrandom.uniform(-(self.frec_variation), self.frec_variation)
  33.         Bladex.AddScheduledFunc(Bladex.GetTime() + self.frecuency + variation, RepeatPeriodicSound, (self,), 'PeriodicSound::PlayPeriodic')
  34.  
  35.     
  36.     def StopPeriodic(self):
  37.         self.OnPlay = 0
  38.  
  39.     
  40.     def persistent_id(self):
  41.         return self.ObjId
  42.  
  43.     
  44.     def __getstate__(self):
  45.         return (1, self.ObjId, self.OnPlay, GameStateAux.SaveEntityAux(self.sound), self.frecuency, self.frec_variation)
  46.  
  47.     
  48.     def __setstate__(self, parm):
  49.         if parm[0] == 1:
  50.             self.ObjId = parm[1]
  51.             self.OnPlay = parm[2]
  52.             ObjStore.ObjectsStore[self.ObjId] = self
  53.             self.sound = GameStateAux.LoadEntityAux(parm[3])
  54.             self.frecuency = parm[4]
  55.             self.frec_variation = parm[5]
  56.         else:
  57.             print 'Warning -> Version mismatch in PeriodicSound.__setstate__()'
  58.             self.OnPlay = 0
  59.             self.sound = None
  60.             self.frecuency = 0
  61.             self.frec_variation = 0
  62.             self.ObjId = ObjStore.GetNewId()
  63.             ObjStore.ObjectsStore[self.ObjId] = self
  64.  
  65.  
  66.  
  67. def CreatePeriodicSound(file_name, sound_name, frecuency, frec_variation, focus):
  68.     persound = PeriodicSound()
  69.     persound.sound = Bladex.CreateEntity(sound_name, 'Entity Sound', focus[0], focus[1], focus[2])
  70.     persound.sound.SetSound(file_name)
  71.     persound.frecuency = frecuency
  72.     persound.frec_variation = frec_variation
  73.     persound.sound.Data = persound
  74.     return persound
  75.  
  76.  
  77. def CreateEntitySound(file_name, sound_name, focus = (0.0, 0.0, 0.0)):
  78.     entsound = Bladex.CreateEntity(sound_name, 'Entity Sound', focus[0], focus[1], focus[2])
  79.     entsound.SetSound(file_name)
  80.     return entsound
  81.  
  82.